package org.ohos.sample.webview.home;

import com.ffsky.litepack.logger.L;
import com.ffsky.litepack.util.StringCompat;
import ohos.aafwk.content.Operation;
import ohos.multimodalinput.event.KeyEvent;
import org.ohos.sample.webview.home.slice.WebAbilitySlice;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;

public class WebAbility extends Ability {

    public  static final String KEY_URL="_webview_url";
    public static final void start(Ability ability,String url){
        Intent intent = new Intent();
        Operation operation = new Intent.OperationBuilder().withDeviceId("")
                .withBundleName(ability.getBundleName())
                .withAbilityName(WebAbility.class)
                .build();
        intent.setOperation(operation);
        intent.setParam(KEY_URL,url);
        ability.startAbility(intent);
    }
    private String TAG="WebAbility";
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
        L.i(TAG, StringCompat.string("onKeyDown->keyCode=",keyCode));
        return super.onKeyDown(keyCode, keyEvent);
    }

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(WebAbilitySlice.class.getName());
    }
}